//
//  itemGridDVD.m
//  Rainbow
//
//  Created by Alex on 27/07/09.
//  Copyright 2009 Erasmus Software. All rights reserved.
//

#import "itemGridDVD.h"

@implementation itemGridDVD

@synthesize imageUID;
@synthesize imageRepresentation;
@synthesize imageTitle;
@synthesize imageSubtitle;
@synthesize imageRepresentationType;

- (id) init
{
	self = [super init];
	if (self != nil)
	{
		imageTitle = [[NSString alloc] initWithString:@"Movie"];
		imageSubtitle = [[NSString alloc] initWithString:@"Director"];
		imageRepresentationType = IKImageBrowserNSImageRepresentationType;
		imageRepresentation = [[NSImage alloc] initByReferencingFile:@"dvd.png"];
		[imageRepresentation retain];
		imageUID = [[NSString alloc] initWithString:[imageRepresentation description]];
	}
	return self;
}

- (id) initWithImage:(NSImage *)image Id:(NSString*)Id
{
	self = [super init];
	if (self != nil)
	{
		[image retain];
		imageTitle = [[NSString alloc] initWithString:@"Movie"];
		imageSubtitle = [[NSString alloc] initWithString:@"Director"];
		imageRepresentationType = IKImageBrowserNSImageRepresentationType;
		imageRepresentation = image;
		imageUID = Id;
	}
	return self;
}

- (id) initWithImage:(NSImage *)image title:(NSString *)title director:(NSString *)director Id:(NSString*)Id;
{
	[image retain];
	self = [self initWithImage:image Id:Id];
	imageTitle = [[NSString alloc] initWithString:title];
	imageSubtitle = [[NSString alloc] initWithString:director];
	return self;
}
/*
- (id) initWithTitle:(NSString*)title director:(NSString*)director
{
	NSLog (@"et un objet DVD");

	self = [self init];
	imageTitle = [[NSString alloc] initWithString:title];
	imageSubtitle = [[NSString alloc] initWithString:director];
	imageRepresentationType = IKImageBrowserNSImageRepresentationType;
	imageRepresentation = [[NSImage alloc] initByReferencingFile:@"dvd.png"];
	[imageRepresentation retain];
	imageUID = [[NSString alloc] initWithString:[imageRepresentation description]];
	return self;
}*/

- (BOOL) isSelectable
{
	return YES;
}

- (void) dealloc
{
	[imageUID release];
	[imageTitle release];
	[imageSubtitle release];
	[imageRepresentation release];
	[imageRepresentationType release];
	[super dealloc];
}


- (void) encodeWithCoder:(NSCoder*) encoder
{
	[encoder encodeObject:imageRepresentation forKey:@"imageRepresentation"];
	[encoder encodeObject:imageRepresentationType forKey:@"imageRepresentationType"];
	[encoder encodeObject:imageUID forKey:@"imageUID"];
	[encoder encodeObject:imageTitle forKey:@"imageTitle"];
	[encoder encodeObject:imageSubtitle forKey:@"imageSubtitle"];
}

- (id) initWithCoder:(NSCoder*) decoder
{
	self = [super init];
	imageRepresentation = [[decoder decodeObjectForKey:@"imageRepresentation"] retain];
	imageRepresentationType = [[decoder decodeObjectForKey:@"imageRepresentationType"] retain];
	imageUID = [[decoder decodeObjectForKey:@"imageUID"] retain];
	imageTitle = [[decoder decodeObjectForKey:@"imageTitle"] retain];
	imageSubtitle = [[decoder decodeObjectForKey:@"imageSubtitle"] retain];
	return self;
}

@end
